




*File to create daily weather data from hourly 

***inputs:
* $Data/Weather_ISD`y' where `y' is 2013-2018
* $Data/Weather_NEWISD`y'
* $Data/PrecipISD`y'.dta

***output:
* $Data/DailyWeather_ISD`y'
* $Data/DailyWeather_NEWISD`y'.dta
* $Data/DailyPrecipISD`y'







forval y = 2013(1)2018 {
		
		
		use $Data/Weather_ISD`y'.dta, clear
			
			gen calm = wind_code =="C" & wind_code ~=""
			
			collapse (mean) temperature wind_speed calm (p50) median_wind_direction= wind_direction   , by(date WBAN USAF)
		
			save $Data/DailyWeather_ISD`y'.dta, replace
		
			
			use $Data/Weather_NEWISD`y'.dta, clear
			
			gen calm = wind_code =="C" & wind_code ~=""
			
			collapse (mean) temperature wind_speed calm (p50) median_wind_direction= wind_direction  , by(date WBAN USAF)

		save $Data/DailyWeather_NEWISD`y'.dta, replace
			
			
			
		use $Data/PrecipISD`y'.dta
			
			collapse (mean) *precip* , by(date WBAN USAF)
			
		save $Data/DailyPrecipISD`y'.dta, replace
		
			
		}
	
	
